
<?php
include '../base/validateAdminLogin.php';
include '../base/layout.php';
?>

<body>

<?php
include '../base/header.php';
?>

<section style="width: 100%;">

    <?php
    include '../base/sidemenu.php';
    ?>

    <aside class="content">

        <div style="margin-top: 65px;margin-left: 100px;">
                 <span style="font-size: 50px;">
                        Creat a new agent
                 </span>
        </div>

        <div style="margin-top: 50px;margin-left: 100px;">
                <span class="user_info_span">
                   The company full name
                </span>
            <input class="user_info_input" id="agent_name" style="width: 400px;" type="text" value="">
        </div>

        <div style="margin-top: 20px;margin-left: 100px;">
                <span class="user_info_span">
                   Tel
                </span>
            <input class="user_info_input" id="agent_tel" style="width: 400px;" type="text" value="">

        </div>

        <div style="margin-top: 20px;margin-left: 100px;">
                <span class="user_info_span">
                    Email
                </span>
            <input class="user_info_input" id="agent_email" style="width: 400px;" type="text" value="">

        </div>

        <div style="margin-top: 20px;margin-left: 100px;">
                <span class="user_info_span">
                   Initial Password
                </span>
            <input class="user_info_input" id="agent_password" style="width: 400px;" type="text" value="">

        </div>

        <div style="margin-top: 40px;margin-left: 100px;">
            <button class="btn" id="btnadd" style="background-color: #2B2B2B;color:white;width: 100px;margin-left: 100px;">
                Confirm
            </button>
        </div>

    </aside>

</section>
</body>
</html>
<script>
    $(function () {

        $("#btnadd").click(function () {

            var agent_name=$("#agent_name").val();
            var agent_tel=$("#agent_tel").val();
            var agent_email=$("#agent_email").val();
            var agent_password=$("#agent_password").val();
            if(agent_name.trim()==""){
                alert(' agent name is not null ');
                return;
            }
            if(agent_tel.trim()==""){
                alert(' agent tel is not null ');
                return;
            }
            if(agent_email.trim()==""){
                alert(' agent email is not null ');
                return;
            }
            if(agent_password.trim()==""){
                alert(' agent password is not null ');
                return;
            }
            $.ajax( {
                url: '../class/agent/agentfunction.php',
                data:{
                    method:'add',
                    agent_name : agent_name,
                    agent_tel : agent_tel,
                    agent_email : agent_email,
                    agent_password : agent_password
                },
                type:'post',
                success:function(data) {
                    if(data==1){
                        window.wxc.xcConfirm('add success', window.wxc.xcConfirm.typeEnum.success);
                    }
                },
                beforeSend: function(){
                    //$('#warning').text('正在处理，请稍等！');
                },
                error : function() {
                    // view("异常！");
                    alert("fail");
                }
            });
        });
    })
</script>


